package com.example.as;

import android.content.Context;
import android.media.Image;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.app.Fragment;
import android.widget.ImageView;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class Fragment_caidan extends Fragment {

    private RecyclerView recyclerView;
    private MyAdapter myAdapter;
    private List<Map<String,Object>> data;
    private Context context;
    public Fragment_caidan() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_caidan, container, false);
        context=this.getActivity();
        recyclerView=view.findViewById(R.id.RecycleView);


        data=new ArrayList<Map<String,Object>>();
        int[] image = new int[]{R.drawable.cy1, R.drawable.ym, R.drawable.dlrb, R.drawable.sze, R.drawable.jjy};

        String[] name={"璐儿","逸姿","张敏","林林","晗晗"};
        String[] height={"162","163","162","165","161"};
        String[] character={"活泼","善良","温柔","可爱","勇敢"};

        for (int i=0;i< name.length;i++) {
            Map<String,Object> map=new HashMap<String,Object>();
//            map.put("image",image[i]);
            map.put("姓名",name[i]);
            map.put("身高",height[i]);
            map.put("性格",character[i]);
            data.add(map);
        }

        myAdapter=new MyAdapter(data,context,image);
//       LinearLayoutManager manager=new LinearLayoutManager(context);
      GridLayoutManager manager = new GridLayoutManager(context, 2);
        recyclerView.setLayoutManager(manager);

        manager.setOrientation(RecyclerView.VERTICAL);

        recyclerView.setAdapter(myAdapter);

        return view;
    }

}